<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /**
         * var arr1 = [1,2,3,4]
         * var arr2 = ['a','b','c','d']
         * 
         * 方式一：创建新数组实现
         *  arr3 = [1,2,3,4,'a','b','c','d']
         * 
         * 方式二：在原数组上实现
         *  arr1 = [1,2,3,4,'a','b','c','d']
         */
        var arr1 = [1, 2, 3, 4]
        var arr2 = ['a', 'b', 'c', 'd']

        // 创建新数组进行合并
        // var newArr = [];//
        // for(var i = 0; i < arr1.length; i++){
        //     newArr[newArr.length] = arr1[i]
        // } 

        // for(var i = 0; i < arr2.length; i++){
        //     newArr[newArr.length] = arr2[i]
        // }
        // console.log(newArr);

        for (var i = 0; i < arr2.length; i++) {
            arr1[arr1.length] = arr2[i];
        }
        console.log(arr1, arr2);
    </script>
</body>

</html>